<?php
declare (strict_types=1);

namespace app\index\controller;

use app\common\model\User;
use think\exception\ValidateException;
use think\facade\View;
use think\response\Json;

class Register extends Base
{
    public function index()
    {
        return View::fetch();
    }


    public function save(): Json
    {
        $param = $this->request->post('', '', $this->filter);
        try {
            $this->validate($param, 'Register');
        } catch (ValidateException $e) {
            return json(['code' => -1, 'msg' => $e->getError()]);
        }
        return json(User::_save($param,''));
    }

}
